/*
*作者---杨彬
*
*/
<template>
    <div>
     <section :class="[imgBg<1?'canUse':(imgBg<2?'used':'outData')]" v-for="oitem in allItemData" @click="backSureOrder(oitem)">
       <span class="money-symbol-warp">
       <span class="money-symbol">￥</span><span
         class="money-number" v-text="oitem.amount">
       </span>
       </span>
       <span class="coupon-name" v-text="oitem.name">
       </span>
       <span class="coupon-explain" v-html="oitem.introduce+'<br>'+oitem.startDate+'至'+oitem.endDate">
       </span>
     </section>

    </div>
</template>
<script type="text/javascript">
  export default {
    data(){
      return {
        getData: null,
      }
    },
    methods:{
      backSureOrder(oitem){
        console.log(oitem)
        if(this.$route.params.id=='0'&&this.$route.params.forPage==='true'){
          var nowProductArr=m$.localStrages.get('orderItemBeans');
          if(nowProductArr.length<=1){
            if(nowProductArr[0].isCake!='1'&&oitem.usedType!='1'){
              m$.localStrages.set('couponId',oitem.id);
              m$.localStrages.set('currentCoupon',oitem);
              this.$router.replace({name:'sureOrder',params:{val:oitem}});
            }
            else if(nowProductArr[0].isCake=='1'&&oitem.usedType!='2'){
              m$.localStrages.set('couponId',oitem.id);
              m$.localStrages.set('currentCoupon',oitem);
              this.$router.replace({name:'sureOrder',params:{val:oitem}});
            }
            else {
              return;

            }
          }
          else {
            let isShowSend=false;
            var nowCake=nowProductArr[0].isCake
            for(var i=0;i<nowProductArr.length;i++){
              if(nowProductArr[i].isCake!=nowCake){
                isShowSend=true;
              }
            }
            if(isShowSend==false){
              if(nowProductArr[0].isCake!='1'&&oitem.usedType!='1'){
                m$.localStrages.set('couponId',oitem.id);
                m$.localStrages.set('currentCoupon',oitem);
                this.$router.replace({name:'sureOrder',params:{val:oitem}});

              }
              else if(nowProductArr[0].isCake=='1'&&oitem.usedType!='2'){
                m$.localStrages.set('couponId',oitem.id);
                m$.localStrages.set('currentCoupon',oitem);
                this.$router.replace({name:'sureOrder',params:{val:oitem}});
              }
              else { 
                return;
              }
            }else{
                m$.localStrages.set('couponId',oitem.id);
                m$.localStrages.set('currentCoupon',oitem);
                this.$router.replace({name:'sureOrder',params:{val:oitem}});
            }
          };

        }
        else {
          return;
        }
      }
    },
 created(){
   console.log()
 },
    props:['allItemData','imgBg']
  }
</script>
<style scoped lang="less">
    @import "couponItem";
</style>
